# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(unittest)

option(USE_CUSTOM_DOWNLOAD "use custom download" OFF)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(IMAGEKNIFE_PATH ${NATIVERENDER_ROOT_PATH}/../../../../)
if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/imageknifec)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/imageknifec/include)

set(CMAKE_CXX_STANDARD 17)

include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/node)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/data)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/border)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/cache)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/include)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/include/data)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/utils)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/task)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/promise)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/request)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/thirdparty/lrucache11)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/thirdparty/libavif/${OHOS_ARCH}/include)
include_directories(${IMAGEKNIFE_PATH}/library/src/main/cpp/thirdparty/boundscheck/third_party_bounds_checking_function/include)
if (USE_CUSTOM_DOWNLOAD)
    include_directories(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/curl/${OHOS_ARCH}/include)
endif()

add_library(unittest SHARED napi_init.cpp
                            imageknife_interface.cpp
                            native_node_test.cpp
                            custom_file_type_parser.cpp
                            custom_transform.cpp
                            custom_data_test.cpp
                            custom_log_printer.cpp
                            custom_key_generator.cpp
                            memory_cache_test.cpp
                            decoder_interceptor_test.cpp
                            download_interceptor_test.cpp)

target_link_directories(unittest PUBLIC ${IMAGEKNIFE_PATH}/library/build/default/intermediates/libs/default/${OHOS_ARCH})

target_link_libraries(unittest PUBLIC libace_napi.z.so libimageknifepro.so libhilog_ndk.z.so libpixelmap.so
                                      libimage_source.so libace_ndk.z.so
                                      imageknifectest
                                      libohcrypto.so)

if(USE_CUSTOM_DOWNLOAD)
    target_compile_definitions(unittest PRIVATE USE_CURL)
    target_link_libraries(unittest PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/curl/${OHOS_ARCH}/lib/libcurl.so.4)
endif()
